	#@head() #@header()
<title>融资需求管理</title>
#@aside("custser")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">添加访问记录</a></li>
            </ul>
            <div class="tab-content">
              <!-- 来访 记录-->
			  <div class="tab-pane active" id="tab_1">
				<div class="box-body">
					<table id="example1" style="width:800px;" class="table table-bordered table-striped dataTable col-md-8" role="grid" aria-describedby="example1_info">
						<tbody>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">查找用户:</td>
						  <td>
							<div  id="a2">
								<select style="width:150px;height:35px;float:left;margin-top:10px;" id="user_Id" class="form-control"></select>
							</div> 
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">用户名:</td>
						  <td class="sorting_1">
							<input id="realName" type="text" class="form-control" placeholder="用户名">
							<input id="userdd" hidden  type="text"  placeholder="用户id">
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">手机号：</td>
						  <td class="sorting_1">
							<input id="mobile" type="text" class="form-control" placeholder="手机号">
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">访问方式：</td>
						  <td class="sorting_1">
							<select id="tel" class="form-control">
								<option value="座机">座机</option>
								<option value="400电话">400电话</option>
								<option value="微信公众号">微信公众号</option>
							  </select>
						  </td>
						</tr>
						<tr id="qk" hidden role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">访问情况：</td>
						  <td class="sorting_1">
							<select id="isValid" class="form-control">
								<option value="已接">已接</option>
								<option value="未接">未接</option>
								<option value="拒接">拒接</option>
								<option value="无响应">无响应</option>
							  </select>
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">访问类型：</td>
						  <td>
							<select id="type" class="form-control">
								<option value="come">来访</option>
								<option value="back">回访</option>
							</select>
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">客户问题：</td>
						  <td class="sorting_1">
							<textarea id="matter" class="form-control" rows="3" placeholder="问题内容"></textarea>
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">解决方法：</td>
						  <td class="sorting_1">
							<textarea id="solve" class="form-control" rows="3" placeholder="解决方法"></textarea>
						  </td>
						</tr>
						<tr role="row" class="odd">
						  <td align="right" style="width:100px;" class="sorting_1">备注：</td>
						  <td class="sorting_1">
							<input id="summary" type="text" class="form-control" placeholder="备注">
						  </td>
						</tr>
						</tbody>
					</table>
				</div>
				<div class="box-footer">
					<button id="submit" type="submit" style="margin-left:10px;" class="btn btn-info ">提交</button>
				  </div>
              </div>
            </div>
        </div>
            <!-- /.tab-content -->
		  #@reposit()
	</section>
</div>
#@footer()
<script>
$(document).ready(function(){
	$("#type").change(function(){
		var type = $("#type").val();
		if(type=="come"){$("#qk").hide();}
	});
	
	$("#submit").click(function() {
		var params = getFormVals("#tab_1");
		ajax("#(path)/visit/edit?token=#(session.token??)",params,function(data){
			if(data.code=='success'){
				layer.msg(data.msg, {icon:1},function(){
					location.href="#(path)/admin/page/custser-"+type;
				});
			}else if(data.code=='error'){
				layer.msg(data.msg, {icon : 2});
			}
		});
	});
	$("#user_Id").select2({
		ajax: {
			type:'GET',
			url: "#(path)/user/list?token=#(session.token??)",
			dataType: 'json',
			delay: 1000,
			data: function (params) {
				return {
					mobile: params.term, // search term 请求参数
					page: params.page
				};
			},
			processResults: function (data, params) {
				var itemList = [];
				var arr = data.data.page.list
				for(item in arr){
					var user = arr[item];
					
					$("#realName").val(user.real_name);
					$("#mobile").val(user.mobile);
					$("#userdd").val(user.id);
					itemList.push({id:user.id, text:user.real_name});
				}
				return {
					results: itemList
				 };
			},
			cache: true
		},
		placeholder:'请输入手机号搜索...',//默认文字提示
		language: "zh-CN",
		tags: false,//允许手动添加
		allowClear: true,//允许清空
		escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
		minimumInputLength: 1,//最少输入多少个字符后开始查询
		formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
		formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
	});
	function GetRequest() {  
	   var url = location.search; //获取url中"?"符后的字串  
	   var theRequest = new Object();  
	   if (url.indexOf("?") != -1) {  
		  var str = url.substr(1);  
		  strs = str.split("&");  
		  for(var i = 0; i < strs.length; i ++) {  
			 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
		  }  
	   }  
	   return theRequest;  
}  
});
</script>
</body>
</html>

